#cs ----------------------------------------------------------------------------
	
	$Author: bjoern.kaiser $
	$LastChangedDate: 2008-05-02 13:09:41 +0000 (Fri, 02 May 2008) $
	
	Script Function:
	Locate folders containing INF files and selection of INFs of a specific
	class.
	
#ce ----------------------------------------------------------------------------

#tidy_parameters=/gd
#include-once

#CS
	Get all subfolders of a given folder
	Returns: array of all subfolders of a given folder
#CE

Func _InfScan_Folders($SourceFolder, $Recursion = 0)
;~ 	If $gBinDebug Then ConsoleWrite("Recursions: " & $Recursion & @CRLF)
	$Recursion += 1
	Local $Search
	Local $File
	Local $FileAttributes
	Local $FullFilePath
	Local $Result[1]
	Local $SubFolders
	
	$Search = FileFindFirstFile($SourceFolder & "\*.*")

	While 1
		If $Search = -1 Then
			ExitLoop
		EndIf

		$File = FileFindNextFile($Search)
		If @error Then ExitLoop

		$FullFilePath = $SourceFolder & "\" & $File
		$FileAttributes = FileGetAttrib($FullFilePath)

		If StringInStr($FileAttributes, "D") Then
;~ 			recurse into subfolders
			$SubFolders = _InfScan_Folders($FullFilePath, $Recursion)
;~ 			If $gBinDebug Then ConsoleWrite($FullFilePath & @CRLF)
			$Result[UBound($Result) - 1] = $FullFilePath
			For $Element In $SubFolders
;~ 				If $gBinDebug Then ConsoleWrite("Element: " & UBound($Result) - 1 & @CRLF)
				ReDim $Result[UBound($Result) + 1]
				$Result[UBound($Result) - 1] = $Element
			Next
		EndIf
	WEnd

	FileClose($Search)
	Return $Result
EndFunc   ;==>_ScanFolder

#CS
	Determine folders containing Inf-Files
	Returns: Array of full paths to directories containing inf-files
#CE

Func _InfScan_HasInf($Folders)
	Local $Result[1]
	For $Element In $Folders
;~ 		Resize array and add path of folder if it contains inf-files
		If FileExists($Element & "\*.inf") Then
			$Result[UBound($Result) - 1] = $Element
			ReDim $Result[UBound($Result) + 1]
		EndIf
	Next
	Return $Result
EndFunc   ;==>_HasInf

#CS
	Locate Inf-Files of a specific class
	Returns: Array of full paths to inf-files of the specified class
#CE

Func _InfScan_InfType($aFolders)
	Local $Result[1]
	Local $Search
	Local $File
	Local $FullFilePath
	Local $binIsHdc
	Local $binIsScsiAdapter
	
	If Not IsArray($aFolders) Then
		SetError(1)
		Return(0)
	EndIf
;~ 	Iterate over all given folders looking for Inf-Files
	For $Element In $aFolders
		$Search = FileFindFirstFile($Element & "\*.inf")
		While 1
			If $Search = -1 Then
				ExitLoop
			EndIf

			$File = FileFindNextFile($Search)
			If @error Then ExitLoop
			$FullFilePath = $Element & "\" & $File
;~ 			Find Inf-Files of the HDC or SCSIAdapter class
			If IniRead($FullFilePath, "Version", "Class", "0") = "HDC" Then $binIsHdc = 1
			If IniRead($FullFilePath, "Version", "Class", "0") = "SCSIAdapter" Then $binIsScsiAdapter = 1
			
			If $binIsHdc Or $binIsScsiAdapter Then
				$Result[UBound($Result) - 1] = $FullFilePath
				ReDim $Result[UBound($Result) + 1]
			EndIf
			$binIsHdc = 0
			$binIsScsiAdapter = 0
		WEnd
		FileClose($Search)
	Next
	Return $Result
EndFunc   ;==>_InfType